<template>
  <div>
    <div v-if="nav_top">
      <div class="crumbs">
        <el-breadcrumb separator="/">
          <el-breadcrumb-item><i class="el-icon-date"></i>添加</el-breadcrumb-item>
          <el-breadcrumb-item>基本添加</el-breadcrumb-item>
        </el-breadcrumb>
      </div>
      <el-radio-group v-model="radio">
        <!-- <el-radio label="banner">轮播图</el-radio>
        <el-radio label="dynamic">动态</el-radio>
        <el-radio label="help">帮助中心</el-radio>
        <el-radio label="service">服务</el-radio>
        <el-radio label="coupon">优惠券</el-radio>
        <el-radio label="school">学校</el-radio>
        <el-radio label="num">号码牌</el-radio>
        <el-radio label="config">配置</el-radio>
        <el-radio label="permission">权限</el-radio>
        <el-radio label="role">角色</el-radio>
        <el-radio label="user">管理员</el-radio>
        <el-radio label="key">关键字</el-radio> -->
        <el-radio v-for="(item,index) in edit_list" :key="index" :label="item.name" :disabled="disabled_list[index]">
          {{item.title}}
        </el-radio>
      </el-radio-group>
      <div>
        <el-button type="primary" @click="viewShow" style="margin-top: 20px;">确认</el-button>
      </div>
    </div>
    <banner-form v-if="view_show == 'banner'"></banner-form>
    <dynamic-form v-if="view_show == 'dynamic'"></dynamic-form>
    <help-form v-if="view_show == 'help'"></help-form>
    <service-form v-if="view_show == 'service'"></service-form>
    <coupon-form v-if="view_show == 'coupon'"></coupon-form>
    <school-form v-if="view_show == 'school'"></school-form>
    <num-form v-if="view_show == 'num'"></num-form>
    <config-form v-if="view_show == 'config'"></config-form>
    <permission-form v-if="view_show == 'perms'"></permission-form>
    <role-form v-if="view_show == 'role'"></role-form>
    <user-form v-if="view_show == 'user'"></user-form>
    <wx-key-form v-if="view_show == 'key'"></wx-key-form>
    <redeem-record-form v-if="view_show == 'redeemRecord'"></redeem-record-form>
  </div>
</template>
<script>
import bus from '../../bus.js';
import BannerForm from '../page/Banner/Form';
import DynamicForm from '../page/Dynamic/Form';
import HelpForm from '../page/Help/Form';
import ServiceForm from '../page/Service/Form';
import CouponForm from '../page/Coupon/Form';
import SchoolForm from '../page/School/Form';
import NumForm from '../page/Num/Form';
import ConfigForm from '../page/Config/Form';
import PermissionForm from '../page/Permission/Form';
import RoleForm from '../page/Role/Form';
import UserForm from '../page/User/Register';
import WxKeyForm from '../page/WX/Form';
import RedeemRecordForm from '../page/Cdkey/Form';
export default {
  components: {
    BannerForm, DynamicForm, HelpForm, ServiceForm,
    CouponForm, SchoolForm, NumForm, ConfigForm,
    PermissionForm, RoleForm, UserForm,WxKeyForm,
    RedeemRecordForm
  },
  data () {
    return {
      radio: undefined,
      view_show: undefined,
      nav_top: true,
      auth: [],
      edit_list: [
        {name: 'banner', title: '轮播图'}, {name: 'dynamic', title: '动态'},{name: 'help', title: '帮助中心'},
        {name: 'service', title: '服务'},{name: 'coupon', title: '优惠券'},{name: 'redeemRecord', title: '兑换码'},
        {name: 'school', title: '学校'},{name: 'num', title: '号码牌'},{name: 'config', title: '配置'},
        {name: 'perms', title: '权限'},{name: 'role', title: '角色'},{name: 'user', title: '管理员'},
        {name: 'key', title: '关键字'}
      ],
      disabled_list: []
    }
  },
  methods: {
    viewShow() {
      if(this.radio !== undefined) {
        this.view_show = this.radio;
        this.nav_top = false;
      }
    }
  },
  mounted () {
    bus.$on('ViewShow', e => {
      this.nav_top = true;
      this.view_show = '';
    })
  },
  created () {
    // 这里，添加权限
    let auth_list = localStorage.getItem('auth_list').split(',')
    auth_list.forEach(el => {
      if (el.indexOf('list') >= 0) {
        this.auth.push(el.substring(0,el.indexOf('list')-1))
      }
    })
    this.edit_list.forEach((element, index) => {
      for (let i = 0; i < this.auth.length; i ++) {
        if (element.name === this.auth[i]) {
          this.disabled_list[index] = false
          return 
        } else {
          this.disabled_list[index] = true
        }
      }
    })
  }
}
</script>
<style scoped>

</style>
